package com.microblogforsim.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.microblogforsim.R;
import com.microblogforsim.ui.TouchImageView;


public class PreviewImgActivity extends AppCompatActivity {
   private TouchImageView preview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_preview_img);
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        preview = findViewById(R.id.activity_preview_img);
        Intent intent = getIntent();

        String Url =  intent.getStringExtra("url");
        Log.d("TAG", "URL:"+Url);
        if(Url.equals("")){
            finish();
        }else
        {
            Glide.with(PreviewImgActivity.this)
                    //加载地址
                    .load(Url)
                    //加载失败时，设置默认的图片
                    .placeholder(R.drawable.loading)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    //显示的位置
                    .into(preview);
        }


        preview.initImageView(dm.widthPixels, dm.heightPixels - 80);
        preview.setOnMoveImageView(new TouchImageView.OnMoveImageView() {
           @Override
           public void next() {

           }

           @Override
           public void last() {

           }

           @Override
           public void click() {
               finish();

           }
       });
    }

}